package com.ws.universal.tools.utils;

/**
 * @author:ws
 * @date: 2021/7/29 14:42
 * @desc 防止按钮连续点击
 */
public final class NoDoubleClickUtils {
    private final static int SPACE_TIME = 500;
    private static long lastClickTime = 0;

    public synchronized static boolean isDoubleClick() {
        long currentTime = System.currentTimeMillis();
        boolean isClick2;
        if (currentTime - lastClickTime > SPACE_TIME) {
            isClick2 = false;
        } else {
            isClick2 = true;
        }
        lastClickTime = currentTime;
        return isClick2;
    }

}
